package com.eastfair.venueservice.service;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.eastfair.boot.request.PageParams;
import com.eastfair.home.dto.ReportSpaceAuditDTO;
import com.eastfair.pay.dto.TransactionOrderDTO;
import com.eastfair.venueservice.dto.BondManageDTO;
import com.eastfair.venueservice.dto.ExhibitionSettlementDTO;
import com.eastfair.venueservice.entity.BondManage;
import com.eastfair.venueservice.vo.BondManageVO;
import com.eastfair.venueservice.vo.ExhibitionSettlementVO;

import java.math.BigDecimal;
import java.util.List;

/**
 * 主场保证金 service.
 *
 * @author dqq
 * @date 2023 /4/18
 */
public interface HomeBondManageService {

    /**
     * 分页查询保证金订单.
     *
     * @param pageParams the page params
     * @return the page
     */
    Page<BondManageVO> listBondManageVOs(PageParams<BondManageDTO> pageParams);

    /**
     * Gets by exhibitor id.
     *
     * @param exhibitorId the exhibitor id
     * @return the by exhibitor id
     */
    List<BondManage> listByExhibitorId(Long exhibitorId);

    /**
     * 展商ID查询保证金订单
     *
     * @param exhibitorIdList the exhibitor id list
     * @return the list
     */
    List<BondManageVO> listVOByExhibitorIdList(List<Long> exhibitorIdList);

    /**
     * 获取主场保证金的结算单
     *
     * @param query the query
     * @return the bond manage settlement by exhibition id
     */
    ExhibitionSettlementVO getHomeBondManageSettlement(ExhibitionSettlementDTO query);

    /**
     * 校验服务商在该展位是否存在保证金订单.
     *
     * @param bondManageDTO the bond manage dto
     * @return the by exhibitor id
     */
    boolean checkSiteBondUnique(BondManageDTO bondManageDTO);

    /**
     * 保存保证金订单.
     *
     * @param bondManageDTO the bond manage dto
     * @return the boolean
     */
    BondManage saveBondManage(BondManageDTO bondManageDTO);

    /**
     * 保存保证金订单
     *
     * @param bondManageDTO the bond manage dto
     * @param isSyncPay     订单是否是同步支付系统订单
     * @return the bond manage
     */
    BondManage saveBondManage(BondManageDTO bondManageDTO, Boolean isSyncPay);

    /**
     * 提交保证金订单.
     *
     * @param bondManageDTO the bond manage dto
     * @return the boolean
     */
    BondManage submitBondManage(BondManageDTO bondManageDTO);

    /**
     * 提交保证金订单.
     *
     * @param bondManageDTO the bond manage dto
     * @param isSyncPay     订单是否是同步支付系统订单
     * @return the bond manage
     */
    BondManage submitBondManage(BondManageDTO bondManageDTO, Boolean isSyncPay);
    /**
     * 提交保证金订单.
     *
     * @param orderNumber the order number
     * @return the boolean
     */
    BondManage submitBondManage(String orderNumber);

    /**
     * 报馆审核通过提交保证金.
     *
     * @param reportSpaceAuditDTO the report space audit dto
     * @return the boolean
     */
    BondManage submitForReportSpace(ReportSpaceAuditDTO reportSpaceAuditDTO);

    /**
     * 是否可扣除保证金.
     *
     * @param exhibitorId        the exhibitor id
     * @param shouldDeductAmount the should deduct amount
     * @return the int 0不可扣除 1可扣除
     */
    int canDeductBond(Long exhibitorId, BigDecimal shouldDeductAmount);

    /**
     * 扣除保证金.
     *
     * @param exhibitorId        the exhibitor id
     * @param shouldDeductAmount the should deduct amount
     * @return the boolean
     */
    BondManage deductBondAmount(Long exhibitorId, BigDecimal shouldDeductAmount);

    /**
     * 扣除保证金
     *
     * @param orderNumber        the order number
     * @param shouldDeductAmount the should deduct amount
     * @return the bond manage
     */
    BondManage deductBondAmount(String orderNumber, BigDecimal shouldDeductAmount);


    /**
     * 退还保证金
     *
     * @param exhibitorId        the exhibitor id
     * @param shouldRefundAmount the refundable amount
     * @return the boolean
     */
    boolean refundBondManage(Long exhibitorId, BigDecimal shouldRefundAmount);

    /**
     * 退还保证金
     *
     * @param orderNumber        the order number
     * @param shouldRefundAmount the should refund amount
     * @return the boolean
     */
    boolean refundBondManage(String orderNumber, BigDecimal shouldRefundAmount);


    /**
     * 取消保证金订单.
     *
     * @param orderNumber the order number
     * @return the boolean
     */
    boolean cancelBondManage(String orderNumber);

    /**
     * 更新保证金状态为已取消.
     *
     * @param orderNumber the order number
     * @return the bond manage
     */
    BondManage updateBondManageCancel(String orderNumber);

    /**
     * 生成支付系统交易订单.
     *
     * @param id the id
     * @return the boolean
     */
    boolean saveTransactionOrder(Long id);

    /**
     * 创建支付系统交易订单
     *
     * @param bondManage the bond manage
     * @return the transaction order dto
     */
     BondManageDTO completeForTransactionOrder(BondManage bondManage);

    /**
     * 发送配置收款商户的站内信.
     *
     * @param bondManageDTO the service order
     * @return the r
     */
    boolean sendConfigPayeeInnerMsg(BondManageDTO bondManageDTO);

    /**
     * 发起退款.
     *
     * @param bondManageDTO the bond manage dto
     * @return the boolean
     */
    boolean applyBondManageRefund(BondManageDTO bondManageDTO);

    /**
     * 异步发送配置收款商户的站内信.
     *
     * @param bondManageDTO the service order
     */
    void asyncSendConfigPayeeInnerMsg(BondManageDTO bondManageDTO);
}